/*
 * TextComponentDelegate.h   0.4.0 / Nov 17, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef TEXTCOMPONENTDELEGATE_H
#define TEXTCOMPONENTDELEGATE_H

#include "Cute4jSwing.h"

#include "ComponentDelegate.h"

// TextComponentDelegate Class. ------------------------------------------------

/*!
 * \brief TextComponent Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT TextComponentDelegate : public ComponentDelegate
{
  Q_OBJECT
protected:
  TextComponentDelegate(JNIEnv *env, jobject obj, QWidget *textComponent);
public slots: // native calls
  virtual void setDocument(JNIEnv *env, jobject document) = 0;
  virtual void setEditable(JNIEnv *env, jboolean editable) = 0;
  virtual void insertText(JNIEnv *env, jstring text) = 0;
  virtual void cut(JNIEnv *env) = 0;
  virtual void copy(JNIEnv *env) = 0;
  virtual void paste(JNIEnv *env) = 0;
  virtual void clear(JNIEnv *env) = 0;
  virtual void selectAll(JNIEnv *env) = 0;
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
public: // native callbacks
  void undoAvailable(jboolean available);
  void redoAvailable(jboolean available);
  void cutAvailable(jboolean available);
  void copyAvailable(jboolean available);
  void pasteAvailable(jboolean available);
  void clearAvailable(jboolean available);
  void selectAllAvailable(jboolean available);
public slots:
  void undoAvailableSlot(bool available);
  void redoAvailableSlot(bool available);
  void clipboardDataChanged();
private:
  bool m_undoAvailable;
  bool m_redoAvailable;
  bool m_cutAvailable;
  bool m_copyAvailable;
  bool m_pasteAvailable;
  bool m_clearAvailable;
  bool m_selectAllAvailable;
private:
  static jmethodID sm_undoAvailableMID;
  static jmethodID sm_redoAvailableMID;
  static jmethodID sm_cutAvailableMID;
  static jmethodID sm_copyAvailableMID;
  static jmethodID sm_pasteAvailableMID;
  static jmethodID sm_clearAvailableMID;
  static jmethodID sm_selectAllAvailableMID;
};

// Macro Definitions. ----------------------------------------------------------

#define TEXT_COMPONENT_DELEGATE \
    (reinterpret_cast<TextComponentDelegate *>(delegate))

#endif // TEXTCOMPONENTDELEGATE_H
